Skip to content

Build your first inspection flow ​

An inspection on the line always has the same four parts: images come in, a model looks at them, a rule decides whether the product passes, and the result goes to a screen. In this guide you join the four in one flow on the controller, with a dataset of packs of biscuits instead of a camera, and see the verdict of each pack on a panel. Each part has a guide of its own that goes further.

What you will learn

  • The four parts of an inspection flow and the node for each one
  • How to try a flow with the images of a dataset
  • How to show its result on a panel

Before you start

You need a controller linked to your project, a dataset with images and a model trained on it; here the «DemoCookies» dataset and a segmentation model that finds each biscuit. The basics of the editor are in Introduction to Node-RED.

1. Bring the images ​

On the line, a camera node brings the images. To build and try the flow, a dataset does the same: drag an inject node and a from-dataset node, and wire them. Each message from the inject node brings one image of the dataset.

Bring the images

2. Choose the dataset ​

Double-click from-dataset. Choose the connection to your project in «Firebase configuration», «Rosepetal Firebase», and the dataset in «Dataset», «DemoCookies». Each message then brings one of its images, at random, in msg.image. See Send dataset images through a flow.

Choose the dataset

3. Send an image every few seconds ​

Click «Done» and open the inject node. In «Repeat», choose «interval» and «every 3 seconds»: once deployed, the flow inspects a pack every 3 seconds, as if a camera took a photo of each one going by.

Send an image every few seconds

4. Run the model ​

Click «Done». Add an inferencer node after from-dataset and open it. Choose the connection to your project in «Firebase» and your model in «Model Name», here «test_01». It adds its predictions to each message, in msg.inference. See Run a trained model on an image.

Run the model

5. Decide pass or fail ​

Click «Done». Add a function node after the inferencer and write the rule of the inspection, here: a pack is good when the model finds its four biscuits. The first line skips an image the model could not judge, such as the ones that arrive while it is still loading.

js
if (!Array.isArray(msg.inference)) return null;
const biscuits = msg.inference.filter((b) => b.confidence >= 0.5).length;
msg.payload = biscuits === 4 ? "OK" : "NOK";
return msg;

See Decide pass or fail from the predictions.

Decide pass or fail

6. Show the verdict on a panel ​

Click «Done». Add a «text» node (ui-text) after the function node and open it. It shows msg.payload on a panel. Write its «Label», «Last pack», and click «+» next to «Group»: a widget goes in a group, and a group in a page.

Show the verdict on a panel

7. Create the page ​

Name the group, «Inspection», and click «+» next to «Page». Name the page, «Biscuit line», choose the dashboard of the controller in «UI», give it an address in «Path», /biscuit-line, and choose the theme. Click «Add» for the page and «Add» for the group. See Show inspection results on a panel.

Create the page

8. Deploy the flow ​

Click «Done» and «Deploy». The model loads on the controller in a few seconds; the packs that arrive meanwhile are refused («Prediction failed: inferencer not ready», in the debug panel) and skipped. From then on every pack goes through the four parts: image, model, rule and screen.

Deploy the flow

9. See the verdicts on the panel ​

Click «Panels» in the top bar and choose «Biscuit line» in the menu. «Last pack» changes with every pack: OK or NOK. From here, a panel can show the image with what the model found, buttons for the operators and counters; see the guides on panels.

See the verdicts on the panel

The four parts ​

PartHereOn a real line
Imagesinject + from-dataseta camera node, triggered by a sensor
Modelinferencerthe same, or the OCR or barcode nodes
Rulefunction nodethe same, often several rules
Screenui-text on a panelthe image canvas, counters, buttons, and a signal to the PLC that rejects the product

Next steps ​

Recorded on Rosepetal release 1.8.15, Node-RED 5.0.10.